#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
typedef long long LL;
using namespace std;
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define REP( i , n ) for ( int i = 0 ; i < n ; ++ i )
#define CLEAR( a , x ) memset ( a , x , sizeof a )
const int maxn=100000;
int num[maxn];
LL sum[maxn<<2],add[maxn<<2];
int N,Q;
void pushup(int rs)
{
    sum[rs]=sum[rs<<1]+sum[rs<<1|1];
}
void pushdown(int rs,int l)
{
    if(add[rs])
    {
        add[rs<<1]+=add[rs];
        add[rs<<1|1]+=add[rs];
        sum[rs<<1]+=add[rs]*(l-(l>>1));
        sum[rs<<1|1]+=add[rs]*(l>>1);
        add[rs]=0;
    }
}

void build(int rs,int l,int r)
{
     if(l==r)
     {
         scanf("%I64d",&sum[rs]);
         return ;
     }
     int mid=(l+r)>>1;
     int l_node = rs*2;
     int r_node = rs*2+1;
     build(l_node,l,mid);
     build(r_node,mid+1,r);
     pushup(rs);
}
void update(int c,int x,int y,int l,int r,int rs)
{
     if(l>=x&&r<=y)
     {
         add[rs]+=c;
         sum[rs]+=(LL)c*(r-l+1);
         return ;
     }
     pushdown(rs,r-l+1);
     int mid=(l+r)>>1;
     int l_node = rs*2;
     int r_node = rs*2+1;
     if(x<=mid)   update(c,x,y,l,mid,l_node);
     if(y>mid)    update(c,x,y,mid+1,r,r_node);
     pushup(rs);
}
LL query(int x,int y,int l,int r,int rs)
{
    if(l>=x&&r<=y)
        return  sum[rs];
    pushdown(rs,r-l+1);
    int mid=(l+r)>>1;
    LL ans=0;
    int l_node = rs*2;
    int r_node = rs*2+1;
    if(x<=mid)   ans+=query(x,y,l,mid,l_node);
    if(y>mid)    ans+=query(x,y,mid+1,r,r_node);
    return ans;
}
int main()
{
     int x,y,z;
     std::ios::sync_with_stdio(false);
     while(~scanf("%d%d",&N,&Q))
     {
         CLEAR(sum,0);
         CLEAR(add,0);
         build(1,1,N);
         char str[2];
         while(Q--)
         {
             scanf("%s",str);
             if(str[0]=='C')
             {
                 scanf("%d%d%d",&x,&y,&z);
                 update(z,x,y,1,N,1);
             }
             else
             {
                 scanf("%d%d",&x,&y);
                 printf("%I64d\n",query(x,y,1,N,1));
             }
         }
     }
     return 0;
}

